#ifndef DINGDANEXCHANGESTANDARDITEMMODEL_H
#define DINGDANEXCHANGESTANDARDITEMMODEL_H

#include <QStandardItemModel>
#include "dingdandetail.h"
#include "product.h"
#include "historyproduct.h"

class DingdanExchangeStandardItemModel : public QStandardItemModel
{
    Q_OBJECT
public:
    explicit DingdanExchangeStandardItemModel(QObject *parent = nullptr);

    bool setData(const QModelIndex &index, const QVariant &value, int role) override;

    QVariant data(const QModelIndex &index, int role) const override;

    void reset();

    void insertItem(QList<DingdanDetail*> details, QList<Product*> products);

    void insertItem(DingdanDetail *detail, Product *product);

    void setItemForRow(int row, DingdanDetail *detail, Product *product);

    void setItemCount(int row, int count);

    DingdanDetail* getDetail(int index);

    Product* getProduct(int index);

    QList<Product*> getProducts();

    QList<DingdanDetail*> getDetails();
signals:
    void updateItemCount(int count);

public slots:

private:
    QStringList header;
    QList<DingdanDetail*> details;
    QList<Product*> products;
};

#endif // DINGDANEXCHANGESTANDARDITEMMODEL_H
